package com.zrs.gmall.order.client;

import com.zrs.gmall.common.result.Result;
import com.zrs.gmall.order.client.impl.OrderDegradeFeignClient;
import com.zrs.gmall.order.model.OrderInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

@FeignClient(value = "service-order", fallback = OrderDegradeFeignClient.class)
public interface OrderFeignClient {

    /**
     * 渲染用户订单确认页面相关参数
     * @return
     */
    @GetMapping("/api/order/auth/trade")
    public Result<Map> tradeDatas();

    /**
     * 根据订单ID查询订单信息
     *
     * @param orderId
     * @return
     */
    @GetMapping("/api/order/inner/getOrderInfo/{orderId}")
    public OrderInfo getOrderInfo(@PathVariable("orderId") Long orderId);

    /**
     * 根据订单编号查询订单信息
     * @param outTradeNo
     * @return
     */
    @GetMapping("/api/order/inner/getOrderInfoByOutTradeNo/{outTradeNo}")
    public OrderInfo getOrderInfoByOutradeNo(@PathVariable("outTradeNo") String outTradeNo);

    /**
     * 提供给秒杀服务调用RestFul接口实现:保存秒杀订单
     * @param orderInfo
     * @return 保存后秒杀订单ID
     */
    @PostMapping("/api/order/inner/seckill/submitOrder")
    public Long submitSeckillOrder(@RequestBody OrderInfo orderInfo);
}
